<!DOCTYPE html>

<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Simple Test</title>
  <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->

  <link rel="stylesheet" type="text/css" href="../../js/jqplot/jquery.jqplot.css" />
  <link rel="stylesheet" type="text/css" href="../../js/jqplot/examples/examples.css" />

  <!-- BEGIN: load jquery -->
  <script language="javascript" type="text/javascript" src="../../js/jqplot/jquery.js"></script>
  <!-- END: load jquery -->

  <!-- BEGIN: load jqplot -->
  <script language="javascript" type="text/javascript" src="../../js/jqplot/jquery.jqplot.js"></script>
  <script language="javascript" type="text/javascript" src="../../js/jqplot/plugins/jqplot.pieRenderer.js"></script>
  <!-- END: load jqplot -->

  <style type="text/css">
    #code {
        font: 10pt "Andale Mono", Monaco, "Courier New", sans-serif ;
        white-space: pre;
    }

    pre {
        background: #D8F4DC;
        border: 1px solid rgb(200, 200, 200);
        padding-top: 1em;
        padding-left: 3em;
        padding-bottom: 1em;
        margin-top: 1em;
        margin-bottom: 3em;

    }

    p {
        margin: 2em 0;
    }
  </style>
<?php
//Formar array de vendedores
$count = 3;//Cantidad de vendedores
//$vendedores = array();//Vendedores;
$nroVentas=0;

$inicioArray="[";
$finArray="]";

$arrayVendedores='';
foreach($vendedores as $vendedor){
    $arrayVendedores.="['".$vendedor->getUsername()."',".$vendedor->getNroVentas()."],";
}

$arrayFinal=$inicioArray.$arrayVendedores.$finArray;

?>

<?php if(!empty($vendedores)): ?>
<script id="example_1" type="text/javascript">$(document).ready(function(){
    s1 = <?php echo $arrayFinal ?> /*[['Maxi',3], ['Pablo',3],];*/

    plot1 = $.jqplot('chart1', [s1], {
        grid: {
            drawBorder: false,
            drawGridlines: true,
            background: '#ffffff',
            shadow:false
        },
        axesDefaults: {

        },
        seriesDefaults:{
            renderer:$.jqplot.PieRenderer,
            rendererOptions: {
                showDataLabels: true
            }
        },
        legend: {
            show: true,
            rendererOptions: {
                numberRows: 1
            },
            location: 's'
        }
    });
});
</script>

<script type="text/javascript">
    $(document).ready(function(){

        $('#code_1').html($('#example_1').html());
        $(document).unload(function() {$('*').unbind(); });

    });
</script>
<?php endif; ?>
  </head>
  <body>
<?php //include sfConfig::get('sf_web_dir')."/js/jqplot/examples/nav.inc"; ?>

      <div id="sf_admin_container">
  <h1><?php echo 'Porcentaje de Ventas por Vendedor'; //, array() 'Editar Producto, Art. %%pro_articulo%% - Talle %%pro_talle%%', array('%%pro_articulo%%' => link_to($configuracion->getProArticulo(), 'configuracion_edit', $configuracion), '%%pro_talle%%' => link_to($configuracion->getProTalle(), 'configuracion_edit', $configuracion)), 'messages') ?></h1>

<?php if(!empty($vendedores)): ?>
    <div id="chart1" style="margin-top:20px; margin-left:20px; width:300px; height:300px;"></div>

    <!--pre id="code_1"></pre-->
<?php else: ?>
<?php echo "No hay vendedores registrados" ?>
<?php endif; ?>


  </body>
</html>